package com.evil.mi.dao;

import com.evil.mi.entity.VideoEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * com.evil.mi.dao
 *
 * @author 白雨浓
 * date: 2018/8/20 15:04
 * content:
 */
@Repository
public interface VideoRepository extends JpaRepository<VideoEntity, Integer> {

    @Query(value = "SELECT * FROM video WHERE state IN :states LIMIT :start,:limit", nativeQuery = true)
    List<VideoEntity> findPage(@Param("states") List<String> states, @Param("start") int start, @Param("limit") int limit);

    @Query(value = "SELECT COUNT(id) FROM video WHERE state IN :states", nativeQuery = true)
    int findCount(@Param("states") List<String> states);

}
